<template>
	<view class="system">
		<!-- 账号安全 -->
		<system-safe></system-safe>
		<!-- 广告 -->
		<system-adC></system-adC>
		<!-- 帮助 -->
		<system-help></system-help>
		<!-- 退出登录 -->
		<button @click="goLogin">{{token ? $t('mine.systen.logout') : $t('mine.systen.signIn')}}</button>
	</view>
</template>

<script>
	import safes from '../../components/system-safe/system-safe.vue'
	import adcs from '../../components/system-adC/system-adC.vue'
	import helps from '../../components/system-help/system-help.vue'
	export default {
		components:{
			safes,
			adcs,
			helps
		},
		data() {
			return {
				token: false
			}
		},
		onShow() {
			this.token = uni.getStorageSync('token') ? true : false
		},
		methods: {
			goLogin(){
				let that = this
				if(this.token) {
					uni.showModal({
						title:'确认退出',
						success(res) {
							console.log(res.confirm);
							if(res.confirm){
							uni.reLaunch({
								url:'../login/login',
								success() {
									that.$store.commit('setIstoken', null)
									let id = uni.getStorageSync('id')
									let pass = uni.getStorageSync('pass')
									uni.clearStorage()
									uni.setStorageSync('id', id)
									uni.setStorageSync('pass', pass)
								}
							})
							}
						}
					})
				} else {
					uni.reLaunch({
						url:'/pages/login/login'
					})
				}
				
			}
		}
	}
</script>

<style>
.system{
	background-color: #F3F3F3;
	height: 100vh;
}
button{
	width: 80%;
	background-color: #FFFFFF;
	position: absolute;
	bottom: 6vh;
	left: 40px;
}
</style>
